//
//  WBHomeController.swift
//  陌路微博
//
//  Created by 张继强 on 16/12/2.
//  Copyright © 2016年 张继强. All rights reserved.
//

import UIKit

fileprivate let CellId = "TableViewCell"

class WBHomeController: WBBaseViewController {
    var listData:[String] = [String]()
    override func viewDidLoad() {
        super.viewDidLoad()
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    override func loadData(){
//        super.loadData()
        DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
            for i in 0 ... 15 {
                if self.PULLUP{
                    //上拉加载
                    self.listData.append("上拉加载+\(i)")
                }else{
                    self.listData.insert(i.description, at: i)
                }
            }
            self.PULLUP = false
            self.refreshControl?.endRefreshing()
            self.tableView?.reloadData()
        }
}
   @objc fileprivate func showFridents(){
        let vc = WBDemoViewController()
        self.navigationController?.pushViewController(vc, animated: true)
        print(#function)
    }

}

extension WBHomeController{
    override func setupUI() {
        super.setupUI()
        navIteam.leftBarButtonItem = UIBarButtonItem.init(title: "好友", fontSize: 16, target: self, action: #selector(showFridents), isBack: false)
        self.tableView?.register(UITableViewCell.self, forCellReuseIdentifier: CellId)
    }
}
extension WBHomeController{
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: CellId, for: indexPath)
        cell.textLabel?.text = self.listData[indexPath.row]
        return cell
    }
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return self.listData.count
    }
}
